//
//  OAFinancialTable3Cell.m
//  OA项目
//
//  Created by innofive on 2018/5/3.
//  Copyright © 2018年 inno. All rights reserved.
//

#import "OAFinancialTable3Cell.h"
#import "BaseTableView.h"
#import "UITableView+tableView.h"
@interface OAFinancialTable3Cell()
@property(nonatomic,strong)RaTreeModel *model;
@property(nonatomic,strong)NSArray *titles;
@property(nonatomic,strong)UIImageView * tuBiaoImage;

@end


@implementation OAFinancialTable3Cell
- (id)initWithStyle:(UITableViewCellStyle)style forViewController:(UIViewController *)ViewController reuseIdentifier:(NSString *)reuseIdentifier forItem:(id)item
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.opaque = YES;
        
        [self onAsInitAddView:self.contentView forViewController:ViewController forItem:item];
    }
    return self;
}

-(void)onAsInitAddView:(UIView *)view forViewController:(UIViewController *)ViewController forItem:(id)item
{
    self.hasTopLine = YES;
  
    self.textLabel.font = kSysFont(kFitW(14));
    self.textLabel.textColor = [UIColor blackColor];
    
    UIImageView * imageView = ({
        UIImageView * l = [UIImageView new];
        l.image = IMAGE(@"iconSlideDown");
        [view addV:l];
        l;
    });
    _tuBiaoImage = imageView;
    
    WSELF(weakSelf);
    [self onMainSetSubViewFrame:^(UIView *view, CGPoint origin, CGSize size, CGPoint center) {
       
        [weakSelf.textLabel sizeToFit];
        weakSelf.textLabel.centerY = kFitH(60)/2;
        if (weakSelf.model) {
            //每一层的布局
            CGFloat left = kFitW(10)+weakSelf.model.level*kFitW(30);
            weakSelf.textLabel.left = left;
        }else
        {
            weakSelf.textLabel.left = kFitW(15);
        }
        
        
       
        [imageView sizeToFit];
        imageView.right =size.width-kFitW(15);
        imageView.centerY = kFitH(60)/2;
 
    }];
    
    
    
}


//    [cell setCellBasicInfoWith:model.name level:level children:model.children.count];
- (void)update:(RaTreeModel *)model forRATreeView:(RATreeView *)treeView AtItem:(id)item
{
    if (model==nil) {
        return;
    }
    
    self.model = model;
   
    self.textLabel.text= model.name;
    
}


@end


